<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <script src="./jquery.js"></script>
    <script>
        // promise的封装
        function request(url) {
            return new Promise((resolve, reject) => {
                $.ajax({
                    url: url,
                    success(data) {
                        resolve(data);
                    },
                    error(err) {
                        reject(err);
                    },
                });
            });
        }
        //   world的请求 promise对象
        request("http://localhost:3000/data")
            .then((res) => {
                console.log(res); //world
                return request("http://localhost:3000/data1")
            })
            // 此处的.then应该是上一个Promise对象调用的
            .then(res => {
                console.log(res); //tom
                return request("http://localhost:3000/data2")
            })
            .then(res => {
                console.log(res); //jerry
            })
    </script>
</body>

</html>